package com.example.bidding_agency_charge_backend.controller;

import com.example.bidding_agency_charge_backend.common.BaseResponse;
import com.example.bidding_agency_charge_backend.common.ErrorCode;
import com.example.bidding_agency_charge_backend.common.ResultUtils;
import com.example.bidding_agency_charge_backend.exception.BusinessException;
import com.example.bidding_agency_charge_backend.model.BinAgen;
import com.example.bidding_agency_charge_backend.model.Result;
import com.example.bidding_agency_charge_backend.service.BidAgenService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 邓哈哈
 * 2024/1/11 17:26
 * Function:
 * Version 1.0
 */

@RestController
@RequestMapping("/serve")
public class BiddingAgencyController {
    @Resource
    private BidAgenService bidAgenService;

    @PostMapping("/calculate")
    public BaseResponse<Result> doCalculate(@RequestBody BinAgen binAgen) {
        if (binAgen == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空");
        }

        Result result = bidAgenService.doCalculate(binAgen);
        return ResultUtils.success(result);
    }
}
